﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Diablo3.Services.Extensions
{
    public static class Int64Extensions
    {
        #region Methods

        /// <summary>
        /// To the unix timestamp.
        /// </summary>
        /// <param name="unixTimestamp">The unix timestamp.</param>
        /// <returns></returns>
        public static DateTimeOffset ToUnixTimestamp(this long unixTimestamp)
        {
            DateTimeOffset unixStartDateTime = new DateTimeOffset(1970, 1, 1, 0, 0, 0, 0, TimeSpan.Zero);

            return unixStartDateTime.AddSeconds(unixTimestamp);
        }

        /// <summary>
        /// To the unix timestamp.
        /// </summary>
        /// <param name="unixTimestamp">The unix timestamp.</param>
        /// <param name="offset">The offset.</param>
        /// <returns></returns>
        public static DateTimeOffset ToUnixTimestamp(this long unixTimestamp, TimeSpan offset)
        {
            DateTimeOffset unixStartDateTime = new DateTimeOffset(1970, 1, 1, 0, 0, 0, 0, offset);

            return unixStartDateTime.AddSeconds(unixTimestamp);
        }

        #endregion
    }
}
